package day04;

import day03.IfelseDemo;

import java.util.Scanner;

public class DoWhileDemo {
    public static void main(String[] args) {
    /*
    do{
    语句块/循环块
    }while(boolean);
    执行过程:
        先执行语句块,再判断boolean的值,若为true则
        继续语句块,反复执行,若boolean为false时,
        循环结束
     */
        Scanner sc=new Scanner(System.in);
        int num=(int)(Math.random()*1000+1);

        System.out.println(num);
        int guess;

        do {
            System.out.println("猜一下");
            guess=sc.nextInt();
            if (guess>num){
                System.out.println("偏大");
            }else if (guess<num){
                System.out.println("偏小");
            }else {
                System.out.println("恭喜你");
            }
        }while (guess!=num);//如果为true则继续执行循环语句,如果为假,则结束循环

    }
}
